package com.leyou.user.service.mapper;

import com.leyou.common.bean.IBaseMapper;
import com.leyou.item.inter.pojo.Brand;
import com.leyou.user.inter.pojo.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface RoleMapper extends IBaseMapper<Role> {

    @Select("select r.id,r.role_code,r.remark from tb_role r left join tb_user_role u  on r.id=u.role_id where u.user_id=#{uid} and r.is_delete=0")
    List<Role> selectRoleByUid(Long uid);

    @Insert("INSERT INTO tb_role_permission(permission_id, role_id) VALUES (#{pid},#{rid})")
    int insertRoleAndPermission(@Param("pid") Long pid, @Param("rid") Long rid);

    @Delete("DELETE from tb_role_permission where role_id = #{rid}")
    int deleteRoleAndPermission(@Param("rid") Long rid);

}